<?php

/**
 * DookhItem form base class.
 *
 * @method DookhItem getObject() Returns the current form's model object
 *
 * @package    dookh
 * @subpackage form
 * @author     Your name here
 * @version    SVN: $Id: sfDoctrineFormGeneratedTemplate.php 29553 2010-05-20 14:33:00Z Kris.Wallsmith $
 */
abstract class BaseDookhItemForm extends BaseFormDoctrine
{
  public function setup()
  {
    $this->setWidgets(array(
      'id'            => new sfWidgetFormInputHidden(),
      'user_id'       => new sfWidgetFormDoctrineChoice(array('model' => $this->getRelatedModelName('User'), 'add_empty' => false)),
      'category_id'   => new sfWidgetFormDoctrineChoice(array('model' => $this->getRelatedModelName('Category'), 'add_empty' => false)),
      'quality'       => new sfWidgetFormChoice(array('choices' => array('old' => 'old', 'new' => 'new', 'reconditioned' => 'reconditioned'))),
      'item_status'   => new sfWidgetFormChoice(array('choices' => array('in stock' => 'in stock', 'out stock' => 'out stock', 'just come' => 'just come'))),
      'status'        => new sfWidgetFormDoctrineChoice(array('model' => $this->getRelatedModelName('Abuse'), 'add_empty' => false)),
      'name'          => new sfWidgetFormInputText(),
      'location'      => new sfWidgetFormInputText(),
      'number_views'  => new sfWidgetFormInputText(),
      'number_points' => new sfWidgetFormInputText(),
      'number_raters' => new sfWidgetFormInputText(),
      'price'         => new sfWidgetFormInputText(),
      'image'         => new sfWidgetFormInputText(),
      'description'   => new sfWidgetFormTextarea(),
      'is_activated'  => new sfWidgetFormInputCheckbox(),
      'expires_at'    => new sfWidgetFormDate(),
      'is_featured'   => new sfWidgetFormInputCheckbox(),
      'created_at'    => new sfWidgetFormDateTime(),
      'updated_at'    => new sfWidgetFormDateTime(),
      'slug'          => new sfWidgetFormInputText(),
    ));

    $this->setValidators(array(
      'id'            => new sfValidatorChoice(array('choices' => array($this->getObject()->get('id')), 'empty_value' => $this->getObject()->get('id'), 'required' => false)),
      'user_id'       => new sfValidatorDoctrineChoice(array('model' => $this->getRelatedModelName('User'))),
      'category_id'   => new sfValidatorDoctrineChoice(array('model' => $this->getRelatedModelName('Category'))),
      'quality'       => new sfValidatorChoice(array('choices' => array(0 => 'old', 1 => 'new', 2 => 'reconditioned'))),
      'item_status'   => new sfValidatorChoice(array('choices' => array(0 => 'in stock', 1 => 'out stock', 2 => 'just come'))),
      'status'        => new sfValidatorDoctrineChoice(array('model' => $this->getRelatedModelName('Abuse'))),
      'name'          => new sfValidatorString(array('max_length' => 32)),
      'location'      => new sfValidatorString(array('max_length' => 32)),
      'number_views'  => new sfValidatorInteger(),
      'number_points' => new sfValidatorInteger(),
      'number_raters' => new sfValidatorInteger(),
      'price'         => new sfValidatorInteger(),
      'image'         => new sfValidatorString(array('max_length' => 64, 'required' => false)),
      'description'   => new sfValidatorString(),
      'is_activated'  => new sfValidatorBoolean(array('required' => false)),
      'expires_at'    => new sfValidatorDate(),
      'is_featured'   => new sfValidatorBoolean(array('required' => false)),
      'created_at'    => new sfValidatorDateTime(),
      'updated_at'    => new sfValidatorDateTime(),
      'slug'          => new sfValidatorString(array('max_length' => 255, 'required' => false)),
    ));

    $this->validatorSchema->setPostValidator(
      new sfValidatorDoctrineUnique(array('model' => 'DookhItem', 'column' => array('slug')))
    );

    $this->widgetSchema->setNameFormat('dookh_item[%s]');

    $this->errorSchema = new sfValidatorErrorSchema($this->validatorSchema);

    $this->setupInheritance();

    parent::setup();
  }

  public function getModelName()
  {
    return 'DookhItem';
  }

}
